<!DOCTYPE html>
<html lang="en-US">
  <head>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-125140709-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'UA-125140709-1');
    </script>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <%= case @view_module do %>
      <% Elixir.BlockScoutWeb.ChainView -> %>
        <link rel="stylesheet" href="<%= static_path(@conn, "/css/main-page.css") %>">
        <link rel="preload" href="<%= static_path(@conn, "/js/chain.js") %>" as="script">
        <link rel="preload" href="<%= static_path(@conn, "/js/chart-loader.js") %>" as="script">
        <link rel="preload" href="<%= static_path(@conn, "/js/token-transfers-toggle.js") %>" as="script">
      <% Elixir.BlockScoutWeb.TransactionView -> %>
        <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
        <link rel="stylesheet" href="<%= static_path(@conn, "/css/custom-scrollbar-styles.css") %>">
        <link rel="preload" href="<%= static_path(@conn, "/js/custom-scrollbar.js") %>" as="script">
      <% _ -> %>
        <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
    <% end %>
    <link rel="preload" href="<%= static_path(@conn, "/js/autocomplete.js") %>" as="script">
    <link rel="preload" href="<%= static_path(@conn, "/images/icons/fontawesome/github.svg") %>" as="image" crossorigin>
    <link rel="preload" href="<%= static_path(@conn, "/images/icons/fontawesome/twitter.svg") %>" as="image" crossorigin>
    <link rel="preload" href="<%= static_path(@conn, "/images/icons/fontawesome/telegram.svg") %>" as="image" crossorigin>
    <link rel="preload" href="<%= static_path(@conn, "/images/icons/fontawesome/bar-chart.svg") %>" as="image" crossorigin>
    <link rel="preload" href="<%= static_path(@conn, "/images/icons/fontawesome/info-circle.svg") %>" as="image" crossorigin>
    <link rel="preload" href="<%= static_path(@conn, "/images/icons/fontawesome/tag.svg") %>" as="image" crossorigin>
    <link rel="preload" href="<%= static_path(@conn, "/css/non-critical.css") %>" as="style" onload="this.onload=null;this.rel='stylesheet'">
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/non-critical.css") %>">
    <%= render_existing(@view_module, "styles.html", assigns) %>

    <link rel="apple-touch-icon" sizes="180x180" href="<%= static_path(@conn, "/apple-touch-icon.png") %>">
    <link rel="icon" type="image/png" sizes="32x32" href="<%= static_path(@conn, "/images/favicon-32x32.png") %>">
    <link rel="icon" type="image/png" sizes="16x16" href="<%= static_path(@conn, "/images/favicon-16x16.png") %>">
    <link rel="manifest" href="<%= static_path(@conn, "/manifest.webmanifest") %>">
    <link rel="mask-icon" href="<%= static_path(@conn, "/safari-pinned-tab.svg") %>" color="#5bbad5">
    <link rel="shortcut icon" type='image/x-icon' href="<%= static_path(@conn, "/images/favicon.ico") %>">
    <meta name="msapplication-TileColor" content="#7dd79f">
    <meta name="msapplication-config" content="<%= static_path(@conn, "/browserconfig.xml") %>">
    <meta name="theme-color" content="#ffffff">

    <%= render_existing(@view_module, "_metatags.html", assigns) || render("_default_title.html") %>

    <script defer data-cfasync="false">
      window.localized = {
        'Blocks Indexed': '<%= gettext("Blocks Indexed") %>',
        'Block Processing': '<%= gettext("Block Mined, awaiting import...") %>',
        'Blocks With Internal Transactions Indexed': '<%= gettext("Blocks With Internal Transactions Indexed") %>',
        'Less than': '<%= gettext("Less than") %>',
        'Market Cap': '<%= gettext("Market Cap") %>',
        'Price': '<%= gettext("Price") %>',
        'Ether': '<%= Explorer.coin_name() %>',
        'Tx/day': '<%= gettext("Tx/day") %>'
      }
    </script>
  </head>

  <body>
    <div class="layout-container">
      <!-- Block for passing backend runtime env variables to frontend -->
      <div id="permanent-dark-mode" class="d-none" ><%= Application.get_env(:block_scout_web, :permanent_dark_mode_enabled) %></div>
      <div id="permanent-light-mode" class="d-none" ><%= Application.get_env(:block_scout_web, :permanent_light_mode_enabled) %></div>
      <div id="indexer-first-block" class="d-none" ><%= Application.get_env(:indexer, :first_block) %></div>
      <input id="js-chain-id" class="d-none" value="<%= Application.get_env(:block_scout_web, :chain_id) %>" />
      <input id="js-json-rpc" class="d-none" value="<%= Application.get_env(:block_scout_web, :json_rpc) %>" />
      <input id="js-coin-name" class="d-none" value="<%= Application.get_env(:explorer, :coin_name) %>" />
      <input id="js-re-captcha-client-key" class="d-none" value="<%= Application.get_env(:block_scout_web, :recaptcha)[:v2_client_key] %>" />
      <input id="js-re-captcha-v3-client-key" class="d-none" value="<%= Application.get_env(:block_scout_web, :recaptcha)[:v3_client_key] %>" />
      <input id="js-re-captcha-disabled" class="d-none" value="<%= Application.get_env(:block_scout_web, :recaptcha)[:is_disabled] %>" />
      <input id="js-network-path" class="d-none" value="<%= Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:path] %>" />
      <!-- -->
      <% show_maintenance_alert = Application.get_env(:block_scout_web, BlockScoutWeb.Chain)[:show_maintenance_alert] %>
      <%= if show_maintenance_alert do %>
        <div class="alert alert-warning text-center mb-0 p-3">
          <%= raw(System.get_env("MAINTENANCE_ALERT_MESSAGE")) %>
        </div>
      <% end %>
      <% hide_indexing_progress_alert = Application.get_env(:indexer, :hide_indexing_progress_alert) %>
      <%= unless hide_indexing_progress_alert do %>
        <% indexed_ratio_blocks = Chain.indexed_ratio_blocks() %>
        <% indexed_ratio =
        case Chain.finished_indexing_from_ratio?(indexed_ratio_blocks) do
        false -> indexed_ratio_blocks
        _ -> Chain.indexed_ratio_internal_transactions()
        end %>
        <%= if not Chain.finished_indexing_from_ratio?(indexed_ratio) do %>
          <div class="alert alert-warning text-center mb-0 p-3" data-seindexed_ratiolector="indexed-status">
            <%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html" %>
            <span data-indexed-ratio-blocks="<%= indexed_ratio_blocks %>" data-indexed-ratio="<%= indexed_ratio %>"></span>
            <%= gettext("- We're indexing this chain right now. Some of the counts may be inaccurate.") %>
          </div>
        <% end %>
      <% end %>
      <% session = Explorer.Account.enabled?() && Plug.Conn.get_session(@conn, :current_user) %>
      <%= render BlockScoutWeb.LayoutView, "_topnav.html", current_user: session, conn: @conn %>
      <%= if session && !session[:email_verified] do %>
        <p class="alert alert-warning" role="alert" style="margin-bottom: 0"><%= gettext("Please confirm your email address to use the My Account feature.") %> <%= gettext("A confirmation email was sent to") %> <a href="mailto:<%= session[:email] %>"><%=session[:email] %></a> <%= gettext "on sign up. Didn’t receive?" %> <a href="/api/account/v1/email/resend" class="ajax"><%= gettext "Resend verification email" %></a>.</p>
      <% else %>
        <p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
      <% end %>
      <p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
      <main class="js-ad-dependant-pt pt-5">
        <%= @inner_content %>
      </main>
      <%= render BlockScoutWeb.LayoutView, "_footer.html", assigns %>
    </div>
    <%= if (
      @view_module != Elixir.BlockScoutWeb.ChainView &&
      @view_module != Elixir.BlockScoutWeb.BlockView &&
      @view_module != Elixir.BlockScoutWeb.BlockTransactionView &&
      @view_module != Elixir.BlockScoutWeb.BlockWithdrawalView &&
      @view_module != Elixir.BlockScoutWeb.AddressView &&
      @view_module != Elixir.BlockScoutWeb.TokensView &&
      @view_module != Elixir.BlockScoutWeb.TransactionView &&
      @view_module != Elixir.BlockScoutWeb.PendingTransactionView &&
      @view_module != Elixir.BlockScoutWeb.TransactionInternalTransactionView &&
      @view_module != Elixir.BlockScoutWeb.TransactionLogView &&
      @view_module != Elixir.BlockScoutWeb.TransactionRawTraceView &&
      @view_module != Elixir.BlockScoutWeb.TransactionTokenTransferView &&
      @view_module != Elixir.BlockScoutWeb.TransactionStateView &&
      @view_module != Elixir.BlockScoutWeb.AddressTransactionView &&
      @view_module != Elixir.BlockScoutWeb.AddressTokenTransferView &&
      @view_module != Elixir.BlockScoutWeb.AddressTokenView &&
      @view_module != Elixir.BlockScoutWeb.AddressWithdrawalView &&
      @view_module != Elixir.BlockScoutWeb.AddressInternalTransactionView &&
      @view_module != Elixir.BlockScoutWeb.AddressCoinBalanceView &&
      @view_module != Elixir.BlockScoutWeb.AddressLogsView &&
      @view_module != Elixir.BlockScoutWeb.AddressValidationView &&
      @view_module != Elixir.BlockScoutWeb.AddressContractView &&
      @view_module != Elixir.BlockScoutWeb.AddressContractVerificationView &&
      @view_module != Elixir.BlockScoutWeb.AddressContractVerificationViaFlattenedCodeView &&
      @view_module != Elixir.BlockScoutWeb.AddressContractVerificationVyperView &&
      @view_module != Elixir.BlockScoutWeb.AddressReadContractView &&
      @view_module != Elixir.BlockScoutWeb.AddressReadProxyView &&
      @view_module != Elixir.BlockScoutWeb.AddressWriteContractView &&
      @view_module != Elixir.BlockScoutWeb.AddressWriteProxyView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.TransferView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.ContractView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.HolderView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.InventoryView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.InstanceView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.Instance.MetadataView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.Instance.OverviewView &&
      @view_module != Elixir.BlockScoutWeb.Tokens.Instance.TransferView &&
      @view_module != Elixir.BlockScoutWeb.VerifiedContractsView &&
      @view_module != Elixir.BlockScoutWeb.APIDocsView &&
      @view_module != Elixir.BlockScoutWeb.Admin.DashboardView &&
      @view_module != Elixir.BlockScoutWeb.SearchView &&
      @view_module != Elixir.BlockScoutWeb.StakesView &&
      @view_module != Elixir.BlockScoutWeb.WithdrawalView
    ) do %>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/app.js") %>"></script>
    <% end %>
    <%=
      for status <- ["error", "warning", "success", "question"] do
        render BlockScoutWeb.CommonComponentsView, "_modal_status.html", status: status
      end
    %>
    <%= render_existing(@view_module, "scripts.html", assigns) %>
    <%= if @view_module == Elixir.BlockScoutWeb.ChainView do %>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/chain.js") %>"></script>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/chart-loader.js") %>"></script>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/token-transfers-toggle.js") %>"></script>
    <% end %>
    <%= if @view_module == Elixir.BlockScoutWeb.TransactionView do %>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/custom-scrollbar.js") %>"></script>
    <% end %>
    <script defer src="<%= static_path(@conn, "/js/autocomplete.js") %>"></script>
    <%= if @view_module in [Elixir.BlockScoutWeb.AddressContractVerificationView, Elixir.BlockScoutWeb.AddressContractVerificationVyperView, Elixir.BlockScoutWeb.AddressContractVerificationViaFlattenedCodeView] do %>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/verification-form.js") %>"></script>
    <% end %>
    <%= if @view_module in [Elixir.BlockScoutWeb.AddressContractVerificationViaMultiPartFilesView, Elixir.BlockScoutWeb.AddressContractVerificationViaJsonView, Elixir.BlockScoutWeb.AddressContractVerificationViaStandardJsonInputView] do %>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/verification-form.js") %>"></script>
      <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/dropzone.js") %>"></script>
    <% end %>
    <script defer data-cfasync="false" src="<%= static_path(@conn, "/js/app_extra.js") %>"></script>
  </body>
</html>
